import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

enum LoadingType { loading, error, empty, none }

class LoadingView extends StatelessWidget {
  final WidgetBuilder builder;
  final LoadingType loadingType;

  const LoadingView({super.key, required this.builder, this.loadingType = LoadingType.loading});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Builder(builder: (context) {
          switch (loadingType) {
            case LoadingType.none:
              return builder(context);
            default:
              return const CupertinoActivityIndicator(radius: 24);
          }
        }),
      ),
    );
  }
}
